﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WebGetter
{
    public class BaiduRule : IWebGetRule
    {
        private const string GET_CURRENT_URL_FORMAT = "";
        public void InitHelper(RegexHelper helper)
        {
            helper.GetByRegexp(Keys.Title, @"title:\""(?<val>[^\""]+)\""");
            helper.GetByRegexp(Keys.TotalNo, @"all_page_num:(parseInt\(\"")?(?<val>\d+)(\""\))?");
            helper.GetByRegexp(Keys.NextUrl, @"<a href=""?(?<val>[^>]+?)""?>下一页</a>");
            helper.GetByRegexp(Keys.PageAuthor, @"author:\s*\""(?<val>.+?)\""");

            helper.GetByRegexp(Keys.PageNo, @"curr_page_num:(parseInt\(\"")?(?<val>\d+)(\""\))?");
            helper.GetByRegexp(Keys.Author, @"(<td[^>]+username=\""(?<val>.+?)\""|<td[^>]+\""author_anonym\"">.+?(?<var>(\d{1,3}\.){3}\.?\*)</td>)");
            helper.GetByRegexp(Keys.Content, "<cc><p[^>]+>(?<val>.+?)</p></cc>");
            helper.GetByRegexp(Keys.Floor, @"<p\s+class=\""floor\"">(?<val>\d+)楼</p>");
            helper.GetByRegexp(Keys.PostTime, @"<li>(?<val>\d{4}-\d{1,2}-\d{1,2}\s+\d{2}:\d{2})</li>");
        }


        public string GetCurrentUrl(RegexHelper helper)
        {
            helper.GetSingleStringByRegexp("");
            return string.Format(GET_CURRENT_URL_FORMAT, "");
        }
    }
}
